package main

import (
	"bytes"
	"fmt"
	"strings"
)

func main() {
	/* 单行字符串 */
	str1 := "hello world"
	fmt.Printf("str1: %v\n", str1)

	/* 多行字符串 使用 '`' 符号表示多行字符串*/
	str2 := `
	<html>
			<head><titile>Hello World</title>
	</html>`
	fmt.Printf("str2: %v\n", str2)

	/* 字符串连接 */
	/* + */
	fmt.Printf("(str1 + str2): %v\n", (str1 + str2))

	/* fmt.Sprintf() */
	fmt.Printf("fmt.Sprintf(\"%%s%%s\", str1, str2): %v\n", fmt.Sprintf("%s%s", str1, str2))

	/* string.Join() */
	fmt.Printf("strings.Join([]string{str1, str2}, \"\"): %v\n", strings.Join([]string{str1, str2}, ""))

	/* bytes.Buffer */
	var buffer bytes.Buffer
	buffer.WriteString(str1)
	buffer.WriteString(str2)
	fmt.Printf("buffer.String(): %v\n", buffer.String())

	/* 字符串的切片 */
	str3 := "Hello World!"
	start_index := 2
	end_index := 5
	fmt.Printf("str3[5] type: %T\tstr3[5]: %v\n", str3[5], str3[5])
	fmt.Printf("str3[%d:%d] type: %T\tstr3[%d:%d]: %v\n", start_index, end_index, str3[start_index:end_index],
		start_index, end_index, str3[start_index:end_index])
}
